<?php

session_start();

date_default_timezone_set('Europe/Berlin');

require_once "../lib/MiniCMS/ConfigLoader.php";

class init {

	/**
	*	Load application
	*/
	public function __construct() {
		/*
		 * Instantiate configLoader class and load configuration
		 */
		new MiniCMS_ConfigLoader();

		try {

			$frontController = Zend_Controller_Front::getInstance();
			$frontController->setControllerDirectory( Zend_Registry::get('config')->module->toArray() );
			$frontController->throwExceptions( true );
			$frontController->setParam('useGlobalDefault', true);
			$frontController->setParam('noViewRenderer', true);
			$frontController->registerPlugin( new ControllerPlugin_Dispatcher() );

			$frontController->dispatch();
                        
		}catch ( Exception $zce ){
			if ( Zend_Registry::get('config')->debug == 1) {
                            MiniCMS_Debug::dump( $zce->getMessage() );
                            MiniCMS_Debug::dump( $zce->getLine() );
                            MiniCMS_Debug::dump( $zce->getFile() );
			    MiniCMS_Debug::dump( $zce );
			}else {
			    $zv = Zend_Registry::get('view');
			    header("HTTP/1.0 404 Not Found");
			    $zv->error = "404 Page not found";
			    echo $zv->render( '404error.html' );
			    return false;
			}
		}
	}

}

new init();

?>